<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@body>
<script src="/misc/app/js/lgs_pda-user.js"></script>
</@body>

<@layout_default>

<div class="box">
    <div class="box-header with-border">
        <#--<span class="pull-right text-muted">共 ${regionList.resultTotal} 条记录</span>-->
            <input type="hidden" id="resultTotal_hidden" value="${pdaUserList.resultTotal}" />
        <form class="form-inline" action="/pdaUser/list">
            <div class="input-group">
                <div class="input-group-addon">用户名：</div>
                <input type="text" class="form-control" style="width: 260px" name="keyword" id="keyword" value="${keyword!}" />
            </div>
            <div class="input-group">
                <div class="input-group-addon">操作节点：</div>
                <input type="text" class="form-control" style="width: 260px" name="depotName" id="depotName" value="${depotName!}" />
            </div>
            <div class="input-group">
                <div class="input-group-addon">操作人：</div>
                <input type="text" class="form-control" style="width: 260px" name="realName" id="realName" value="${realName!}" />
            </div>
            <div class="input-group">
                <div class="input-group-addon">状态</div>
                <select class="form-control" name="sta" id="sta">
                    <option value="">全部</option>
                    <option value="1" ${(sta?exists && sta == 1)?string("selected","")}>正常</option>
                    <option value="0" ${(sta?exists && sta == 0)?string("selected","")}>停用</option>
                </select>

            </div>

            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
            <button type="button" class="btn btn-default" name="btn_new_user" data-toggle="modal" data-target="#md_new_user"><i class="fa fa-plus"></i> 创建用户</button>
        </form>
        <#--<form class="form-inline hide">-->
            <#--<input class="form-control"/>-->
            <#--<input type="email" class="form-control"/>-->
            <#--<button type="submit" class="btn btn-default">Send invitation</button>-->
        <#--</form>-->
    </div>

    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>操作节点</th>
                <th>操作人</th>
                <th>录入时间</th>
                <th>录入人</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            <#if (pdaUserList.result?size > 0)>
                <#list pdaUserList.result as item>
                    <tr>
                        <td>${item.id!}</td>
                        <td>${item.account!}</td>
                        <td>${item.depotName!}</td>
                        <td>${item.realName!}</td>
                        <td>${item.cTime?number_to_datetime}</td>
                        <td>${item.cAdmin!}</td>
                        <td><#if item.sta==1><span class="text-green">正常</span><#elseif item.sta==0><span class="text-yellow">停用</span><#else><span class="text-danger">未知</span></#if></td>
                        <td>
                            <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#md_edit_user" data-user-id="${item.id}">编辑</button>
                        </td>
                    </tr>
                </#list>
            <#else>
                <tr>
                    <td class="text-center text-muted" colspan="6"><i class="fa fa-info-circle"></i> 没有记录</td>
                </tr>
            </#if>
        </table>
        <table class="table table-striped table-hover">
            <tr>
                <td colspan="13" style="text-align:right;background-color:white;">
                    <a href="javascript:void(0);" name="btn_export"><i class="glyphicon glyphicon-save"></i> 数据导出</a>
                </td>
            </tr>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/pdaUser/list?keyword=${keyword!}&sta=${sta!}&depotName=${depotName!}&realName=${realName!}&page=$page",pdaUserList.page,pdaUserList.pageTotal/>
    </div>
</div>

<!-- new -->
<div class="modal" id="md_new_user" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus"></i> 创建用户</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_new_user">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 用户名:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="account" placeholder="仅限汉字、数字、字母"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 密码:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="pwd" placeholder="仅限数字、字母"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 确认密码:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="confirmPwd" placeholder="仅限数字、字母"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 操作人:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="realName" placeholder="仅限汉字、数字、字母"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 操作节点:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="depotId">
                                <option value="">请选择</option>
                                <#list depotList as item>
                                    <option value="${item.id}">${item.name}</option>
                                </#list>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 适用操作类型:</label>
                        <div class="col-sm-10" style="padding-top: 5px;">
                            <#if (nodeList?size > 0)>
                                <#list nodeList as item>
                                    <input type="checkbox" value="${item.id}" name="nodes"/> ${item.name}
                                    <#if (item_index?if_exists+1)%5 == 0> <br/> </#if>
                                </#list>
                            </#if>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 状态:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="sta">
                                <option value="1">正常</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_new_user">保存</button>
            </div>
        </div>
    </div>
</div>

<!-- edit -->
<div class="modal" id="md_edit_user" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus"></i> 创建用户</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_user">
                    <input type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 用户名:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="account"  readonly="readonly"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 密码:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="pwd"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 确认密码:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="confirmPwd"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 操作人:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="realName" readonly="readonly"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 操作节点:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="depotName" readonly="readonly"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 适用操作类型:</label>
                        <div class="col-sm-10" style="padding-top: 5px;">
                            <#if (nodeList?size > 0)>
                                <#list nodeList as item>
                                    <input type="checkbox" value="${item.id}" name="editNodes" class="nodes_${item.id}" />${item.name}
                                    <#if (item_index?if_exists+1)%5 == 0> <br/> </#if>
                                </#list>
                            </#if>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 状态:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="sta">
                                <option value="1">正常</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_edit_user">保存</button>
            </div>
        </div>
    </div>
</div>

</@layout_default>